var app = getApp();
var wUtils = require('../../utils/wechatRequest.js');
Page({

   /**
    * 页面的初始数据
    */
   data: {
      fun: [,

      ],
      userInfo:{},
      showMobileBindMenu: true
   },

   /**
    * 生命周期函数--监听页面加载
    */
   onLoad: function (options) {
    //  this.setData({
    //    userInfo: app.globalData.userInfo
    //  });
    // var that = this;
    //  wUtils.doGet('/app/user/info', null, function (res) {
    //    if (res.code == 0) {
    //      app.globalData.userInfo = res.userEntity;
    //      if ( res.userEntity.mobile != null && res.userEntity.mobile != '') {
    //        // showMobileBindMenu = false;
    //      }
    //      var funArray = new Array();
         
    //      var fansObj = {};
    //      fansObj.key = 1;
    //      fansObj.title = '粉丝';
    //      fansObj.num = res.userEntity.fansCount;
    //      fansObj.url = '/pages/fans/fans';

    //      funArray.push(fansObj);

    //      var pointObj = {};
    //      pointObj.key = 2;
    //      pointObj.title = '积分';
    //      pointObj.num = res.userEntity.userPoint;
    //      pointObj.url = '/pages/integralHome/integralHome';

    //      funArray.push(pointObj);
    //      that.setData({
    //        userInfo: res.userEntity,
    //        fun: funArray
    //      })
    //    }
    //  });
   },
   toFun(e) {
      var obj = e.currentTarget.dataset;
      wx.navigateTo({
         url: obj.url,
      })
   },
   /**
    * 生命周期函数--监听页面初次渲染完成
    */
   onReady: function () {
     console.log('onReady');
   },

   /**
    * 生命周期函数--监听页面显示
    */
   onShow: function () {
     console.log('onShow');
     var that = this;
     wUtils.doGet('/app/user/info', null, function (res) {
       if (res.code == 0) {
         app.globalData.userInfo = res.userEntity;
         if (res.userEntity.mobile != null && res.userEntity.mobile != '') {
           that.setData({
             showMobileBindMenu: false
           })
         }
         var funArray = new Array();

         var fansObj = {};
         fansObj.key = 1;
         fansObj.title = '粉丝';
         fansObj.num = res.userEntity.fansCount;
         fansObj.url = '/pages/fans/fans';

         funArray.push(fansObj);

         var pointObj = {};
         pointObj.key = 2;
         pointObj.title = '积分';
         pointObj.num = res.userEntity.userPoint;
         pointObj.url = '/pages/integralHome/integralHome';

         funArray.push(pointObj);
         that.setData({
           userInfo: res.userEntity,
           fun: funArray
         })
       }
     });
   },

   /**
    * 生命周期函数--监听页面隐藏
    */
   onHide: function () {

   },

   /**
    * 生命周期函数--监听页面卸载
    */
   onUnload: function () {

   },

   /**
    * 页面相关事件处理函数--监听用户下拉动作
    */
   onPullDownRefresh: function () {

   },

   /**
    * 页面上拉触底事件的处理函数
    */
   onReachBottom: function () {

   },

   /**
    * 用户点击右上角分享
    */
   onShareAppMessage: function () {

   }
})